import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Atras here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Atras extends Boton
{
    /**
     * Act - do whatever the Atras wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    /**
     * Constructor
     */
    public Atras()
    {
       GreenfootImage imagen = new GreenfootImage("flecha.gif");
       imagen.scale (60,60);
       setImage(imagen);
    }
    public void act() 
    {
         reiniciaTodo();
    }  
    /**
     * Vuelve a dibujar el menu si presiono el objeto atras y remueve todos los objetos que puedan estar en ese momento
     */
    public void reiniciaTodo()
    {
    
        if(Greenfoot.mouseClicked(this))
         {
             Greenfoot.playSound("click.mp3");
             MoveWorld mundo = (MoveWorld)this.getWorld();
             mundo.dibujaMenu();
             mundo.setActivaScroll(true);
             mundo.removeObject(this);
             mundo.removeObjects(mundo.getObjects(Rama.class));
             mundo.removeObjects(mundo.getObjects(Jugador.class));
             mundo.removeObjects(mundo.getObjects(Vida.class));
             mundo.removeObjects(mundo.getObjects(Enemigo.class));
             mundo.removeObjects(mundo.getObjects(Bonos.class));
             mundo.removeObjects(mundo.getObjects(Letrero.class));
             mundo.removeObjects(mundo.getObjects(ScoreBoard.class)); 
        }
    
    }
}
